<?php

session_start();

include_once "src/controller/blmanagement/ResourceManagement.php";
include_once "src/model/Resource.php";
include_once "src/misc/ClientReponseGenerator.php";

try {
    
    $resource = new Resource();
    $resource->setResourceName($_POST["addResourceName"]);
    $resource->setResourceDescription($_POST["addResourceDescription"]);
    $resource->setResourceLocation($_POST["addResourceLocation"]);
    $resource->setResourceGroup($_POST["addResourceGroupName"]);
    $resource->setOwnerId($_POST["addResourceOwner"]);
    $resource->setResourceStatus(1);

    if (ResourceManagement::addResource($resource)) {
        echo ClientReponseGenerator::simpleJsonResponse(1, "", "");
    } else {
        throw new Exception();
    }
    sleep(1);
} catch (Exception $e) {
    echo ClientReponseGenerator::simpleJsonResponse(0, "AddResourceException", "");
}

?>
